package com.test2;

import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.v113.performance.Performance;
import org.openqa.selenium.devtools.v113.performance.model.Metric;

import java.util.List;
import java.util.Optional;

public class performanceMetricsExample
{
    public static void main(String[] args)
    {
        System.setProperty("webdriver.chrome.driver", "C:\\\\Program Files\\\\Google\\\\Chrome\\\\Application\\\\chromedriver.exe");
        // 创建驱动对象
        ChromeDriver webDriver = new ChromeDriver();

        DevTools devTools=webDriver.getDevTools();
        devTools.createSession();
        devTools.send(Performance.enable(Optional.empty()));
        List<Metric> metricList = devTools.send(Performance.getMetrics());
        webDriver.get("https://www.baidu.com");
        //webDriver.quit();

        for (Metric m : metricList)
        {
            System.out.println(m.getName()+" = "+m.getValue());
        }
    }
}
